﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace PWAsker
{
    /// <summary>
    /// Interaction logic for PropertiesWnd.xaml
    /// </summary>
    public partial class PropertiesWnd : Window
    {
        Executable objExecutable;
        
        public PropertiesWnd(Executable objExecutable)
        {
            this.objExecutable = objExecutable;

            InitializeComponent();

            //initialize window
            textBoxCommand.Text = objExecutable.ExecCommand;
            checkWaitForCommand.IsChecked = objExecutable.WaitForCommand;
            if (checkWaitForCommand.IsChecked == true)
            {
                labelWaitSecs1.Content = "Wait for max.";
            }
            else
            {
                labelWaitSecs1.Content = "Wait for";
            }

            textSecWait.Text = Convert.ToString(objExecutable.WaitSecs);
            if (textSecWait.Text == "0")
            {
                labelWaitSecs1.IsEnabled = false;
                labelWaitSecs2.IsEnabled = false;
            };
        }

        private void checkWaitForCommand_Checked(object sender, RoutedEventArgs e)
        {
            labelWaitSecs1.Content = "Wait for max.";
            objExecutable.WaitForCommand = true;
        }

        private void checkWaitForCommand_Unchecked(object sender, RoutedEventArgs e)
        {
            labelWaitSecs1.Content = "Wait for";
            objExecutable.WaitForCommand = false;
        }

        private void textSecWait_LostFocus(object sender, RoutedEventArgs e)
        {
            objExecutable.WaitSecs = Convert.ToInt32(textSecWait.Text);

            if (textSecWait.Text == "0")
            {
                labelWaitSecs1.IsEnabled = false;
                labelWaitSecs2.IsEnabled = false;
            };
        }

        private void textSecWait_GotFocus(object sender, RoutedEventArgs e)
        {
                labelWaitSecs1.IsEnabled = true;
                labelWaitSecs2.IsEnabled = true;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

    }
}
